package com.wzy.Jdbc封装.controller;

import com.wzy.Jdbc封装.pojo.News_category;
import com.wzy.Jdbc封装.service.option_News_category;
import com.wzy.Jdbc封装.service.Impl.option_News_categoryImpl;

import java.sql.SQLException;
import java.util.Date;
import java.util.List;

public  class  News_categoryController {
    //注入服务层
   private static option_News_category news_category = new option_News_categoryImpl();

//    //根据id查询信息
    public static void select(News_category category)throws SQLException{
        List<News_category> list = news_category.selectById(category);
        //遍历集合读取数据
        for (News_category c : list){
            System.out.println(c.getId()+"-------"+c.getName()+"-------"+c.getDate());
        }
    }
//
//    //根据id删除信息
    public  static  void delete(News_category category) throws SQLException {
        int i = news_category.deleteById(category);
        System.out.println(i>0?"删除成功":"删除失败");
    }
//
//    //根据id修改名称name
    public  static  void update(News_category category) throws SQLException {
        int i = news_category.updateById(category);
        System.out.println(i>0?"修改成功":"修改失败");
    }

    //新增信息
    public  static  void insert(News_category news) throws SQLException {

        int i = news_category.insertNews(news);
        System.out.println(i>0?"新增成功":"新增失败");
    }

}
